public class Demo5 {
    public static void main(String[] args) throws InterruptedException {
        Object locker1 = new Object();
        Object locker2 = new Object();
        Object locker3 = new Object();

        Thread t1 = new Thread(()->{
            synchronized (locker1){
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("A");
            synchronized (locker2){
                locker2.notify();
            }
        });

        Thread t2 = new Thread(()->{
            synchronized (locker2){
                try {
                    locker2.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("B");
            synchronized (locker3){
                locker3.notify();
            }
        });

        Thread t3 = new Thread(()->{
            synchronized (locker3){
                try {
                    locker3.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("C");
        });

        t1.start();
        t2.start();
        t3.start();
        Thread.sleep(1000);//确保t1进入time_wait状态
        synchronized (locker1){
            locker1.notify();
        }
    }
}
